ARG FLINK_VERSION=1.20.0
ARG FLINK_CDC_VERSION=3.3.0

FROM apache/flink:${FLINK_VERSION} AS flink
ARG FLINK_CDC_VERSION

# MySQL Driver
ADD --chown=flink:flink --chmod=644 https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.27/mysql-connector-java-8.0.27.jar /opt/flink/lib/mysql-connector-java-8.0.27.jar
## CDC
ADD --chown=flink:flink --chmod=644 https://dlcdn.apache.org/flink/flink-cdc-${FLINK_CDC_VERSION}/flink-cdc-${FLINK_CDC_VERSION}-bin.tar.gz $FLINK_HOME/
RUN tar -xzf $FLINK_HOME/flink-cdc-${FLINK_CDC_VERSION}-bin.tar.gz -C $FLINK_HOME/ && \
    rm $FLINK_HOME/flink-cdc-${FLINK_CDC_VERSION}-bin.tar.gz && \
    mv $FLINK_HOME/flink-cdc-${FLINK_CDC_VERSION}/lib/flink-cdc-dist-${FLINK_CDC_VERSION}.jar $FLINK_HOME/lib/
# ## Connectors
# # Mysql and Starrocks
ADD --chown=flink:flink --chmod=644 https://repo1.maven.org/maven2/org/apache/flink/flink-cdc-pipeline-connector-mysql/${FLINK_CDC_VERSION}/flink-cdc-pipeline-connector-mysql-${FLINK_CDC_VERSION}.jar $FLINK_HOME/lib/
ADD --chown=flink:flink --chmod=644 https://repo1.maven.org/maven2/org/apache/flink/flink-cdc-pipeline-connector-starrocks/${FLINK_CDC_VERSION}/flink-cdc-pipeline-connector-starrocks-${FLINK_CDC_VERSION}.jar $FLINK_HOME/lib/
